package com.ai.producer.BIProducer;

import com.ai.common.constant.BIMQConstant;
import com.ai.common.interfaces.BIInterFace;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.amqp.AmqpException;
import org.springframework.amqp.rabbit.core.RabbitTemplate;

import javax.annotation.Resource;

@DubboService
@Slf4j
public class BIProducer implements BIInterFace {
    @Resource
    private RabbitTemplate rabbitTemplate;
    @Override
    public void sendMessageBI(String message) {
        try {
            rabbitTemplate.convertAndSend(BIMQConstant.AI_EXCHANGE_NAME,BIMQConstant.AI_ROUTING_KEY,message);
        } catch (AmqpException e) {
            log.info("发送异常：{}",e.getMessage());
            throw new RuntimeException(e);
        }
    }
}
